/**
 * Created by mrichana on 9/21/13.
 */
'use strict';
angular.module('hierarchy', ['uuid'])
	.factory('patient', function(uuidGenerator){
		var patientfactory = {
			new: function(){
				var patient = {
					id: uuidGenerator.new(),
					actions: [
						{timestamp: new Date().getTime(), action: 'create'}
					]
				};
				return patient;
			},
			list: {
				data: {},
				add: function(patient){
					patient = patient || patientfactory.new();
					this.data[patient.id]=patient;
					return patient;
				},
				remove: function(item){
					var id = item.id || item;
					delete this.data[id];
				}
			}
		};
		return patientfactory;
	})
